#!/bin/bash

#delete old coding folder
rm -rf ./Coding

if [ $# != 2 ]
then
	echo "Usage $0 NumberOfCores MT-Method"
#	exit -1
fi

#encode with the thread count given on command line
cmd_encode="./encoder rand_10MB 6 4 reed_sol_van 16 1024 50000000 $1 $2"
echo $cmd_encode
$cmd_encode

#delete two devices
rm -f ./Coding/rand_10MB_k1
echo "Delete disk 0"
rm -f ./Coding/rand_10MB_k3
echo "Delete disk 2"
rm -f ./Coding/rand_10MB_m1
echo "Delete disk 6"
rm -f ./Coding/rand_10MB_m3
echo "Delete disk 8"

#try to decode
cmd_decode="./decoder rand_10MB $1 $2"
echo $cmd_decode
$cmd_decode

#see if the decoded file matches the original
result=$(diff ./rand_10MB ./Coding/rand_10MB_decoded)
if [[ $result != "" ]]
then
	echo "Failure"
	echo $result
else
	echo "Success!"
fi

#rm -rf ./Coding
